<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <?php  echo $html->script(array("jquery.min.js","jquery.form.js","jquery.validate.js","jquery.pagination.js","jquery.tablesorter.min.js","jquery.tablednd.js","datepicker.js")); ?>
<?php
//echo $this->Html->css('datepicker');
?>
<script type="text/javascript">
// <![CDATA[
function pad(value, length) {
        length = length || 2;
        return "0000".substr(0,length - Math.min(String(value).length, length)) + value;
};
// ]]>
</script>
</head>
<body>
<div id="result">
<div class="div_header1">Add New Super-Admin</div>
<form method="post" id="add_admin" action="<?php echo Configure::read('base_url')."users/add_superadmin";?>">
<table cellspacing="0" id="mytable"  style="float:left;">
          <tbody>
    <tr>
    <td colspan="2">
    <table width="100%" border="0" cellspacing="0" cellpadding="3" style="float:left;">
    <tr><td colspan="4" style="color: red;">All the entries with * are mandatory for signup. Please fill in all information correctly.</td></tr>
    <tr>
    <td width="266" align="right">
    First Name*
    </td>
    <td width="247">
        <?php
        echo $this->Form->input('User.first_name',array('label'=>false,'div'=>false,'class'=>'required'));
        ?>
    </td>
    <td width="266" align="right">
   Last Name*
    </td>
    <td width="247">
        <?php
        echo $this->Form->input('User.last_name',array('label'=>false,'div'=>false,'class'=>'required','size'=>'19'));
        ?>
    </td>
    </tr>
     <tr >
    <td width="266" align="right">
    Street Address*
    </td>
    <td width="247" colspan="3">
        <?php
        echo $this->Form->input('address',array('label'=>false,'div'=>false,'class'=>'required medium'));
        ?>
    </td>

    </tr>
     <tr >
    <td width="266">
   
    </td>
    <td width="247" colspan="3">
        <?php
        echo $this->Form->input('address1',array('label'=>false,'div'=>false,'class'=>'medium'));
        ?>
    </td>

    </tr>
     <tr >
    <td width="266" align="right">
   City*
    </td>
    <td width="247" colspan="3">
        <?php
        echo $this->Form->input('User.city',array('label'=>false,'div'=>false,'class'=>'required'));
        ?>
    </td>

    </tr>
    <tr>
    <td width="266" align="right">
    State*
    </td>
    <td width="247">
        <?php
        echo $this->Form->input('User.state_id',array('label'=>false,'div'=>false,'class'=>'required','empty'=>'Select'));
        ?>
    </td>
    <td width="266" align="right">
   Zip*
    </td>
    <td width="247">
        <?php
        echo $this->Form->input('User.zip',array('label'=>false,'div'=>false,'class'=>'required','size'=>'19'));
        ?>
    </td>
    </tr>
     <tr >
    <td width="266" align="right">
   Country*
    </td>
    <td width="247" colspan="3">
        <?php
        echo $this->Form->input('User.country_id',array('label'=>false,'div'=>false,'class'=>'required','empty'=>'Select'));
        ?>
    </td>

    </tr>
 <tr >
    <td width="266" align="right">
Primary Phone # *
    </td>
    <td width="247" colspan="3">
        <?php
        echo $this->Form->input('phone1',array('label'=>false,'div'=>false,'maxlength'=>"3",'size'=>'4','style'=>'float:left;margin-right:10px;'));
         echo $this->Form->input('phone2',array('label'=>false,'div'=>false,'maxlength'=>"4",'size'=>'5','style'=>'float:left;margin-right:10px;'));
          echo $this->Form->input('phone3',array('label'=>false,'div'=>false,'maxlength'=>"3",'size'=>'4','class'=>'required'));
        ?>
    </td>

    </tr>
     <tr>
    <td width="266" align="right">
   Email*
    </td>
    <td width="247">
        <?php
        echo $this->Form->input('email',array('id'=>'email','name'=>'email','label'=>false,
            'div'=>false,'class'=>'required email'));
        ?>
    </td>
    <td width="266" align="right">
  Confirm Email*
    </td>
    <td width="247">
        <?php
        echo $this->Form->input('cemail',array('label'=>false,'name'=>'cemail','div'=>false,'size'=>'19'));
        ?>
    </td>
    </tr>
     <tr >
    <td width="266" align="right">
   User Id*
    </td>
    <td width="247" colspan="3">
        <?php
        echo $this->Form->input('User.username',array('label'=>false,'div'=>false,
            'name'=>'username','id'=>'username'));
        ?>
    </td>

    </tr>
     <tr>
    <td width="266" align="right">
   Password*
    </td>
    <td width="247">
        <?php
        echo $this->Form->input('password',array('label'=>false,'div'=>false,
            'class'=>'required','name'=>'password','id'=>'password','type'=>'password'));
        ?>
    </td>
    <td width="266" align="right">
  Confirm Password*
    </td>
    <td width="247">
        <?php
        echo $this->Form->input('cpassword',array('label'=>false,'div'=>false,
            'class'=>'required','name'=>'cpassword','id'=>'cpassword','type'=>'password','size'=>'19'));
        ?>
    </td>
    </tr>
     <tr >
    <td width="266" align="right">
   Secret Question*
    </td>
    <td width="247" colspan="3">
        <?php
       echo $this->Form->input('User.secretquestion_id',array('empty'=>'Select your Secret question','div'=>false,'label'=>false,'class'=>'required','style'=>"width:195px"));
        ?>
    </td>

    </tr>
    <tr >
    <td width="266" align="right">
   Your Secret Answer*
    </td>
    <td width="247" colspan="3">
        <?php
        echo $this->Form->input('User.ques_ans',array('label'=>false,'div'=>false,'class'=>'required'));
        ?>
    </td>

    </tr>
    <tr >
    <td width="266" align="right">
   Date of Birth*
    </td>
    <td width="247" colspan="3"  align="left">
       <input type="text" readonly class="w16em required" id="selectDate1" name="data[User][dateofbirth]" />
        <?php
        /*echo $this->Form->input('User.dateofbirth',array('label'=>false,'div'=>false,
            'class'=>'required','minYear'=>1900));*/
        ?>
<script type="text/javascript">
     var today     = new Date(),
            // low range, 35 days before today's date
            //rangeLow  = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 35),
			// low range, form today's date
            rangeLow  = new Date(today.getFullYear()-150, today.getMonth(), today.getDate()),
            // high range, one year after today's date
            rangeHigh = new Date(today.getFullYear()-18, today.getMonth(), today.getDate())

        var opts = {
                formElements:{"selectDate1":"Y-ds-m-ds-d"},
                showWeeks:true,
                statusFormat:"l-cc-sp-d-sp-F-sp-Y",
                // Set some dynamically calculated ranges
                rangeLow:rangeLow.getFullYear() + "" + pad(rangeLow.getMonth()+1) + pad(rangeLow.getDate()),
                rangeHigh:rangeHigh.getFullYear() + "" + pad(rangeHigh.getMonth()+1) + pad(rangeHigh.getDate())

        };
        if(jQuery("#fd-selectDate1").html()!=null){
           jQuery('#fd-selectDate1').remove();
        }
        datePickerController.createDatePicker(opts);



     // <![CDATA[
      /* var opts = {
                formElements:{"selectDate":"Y-ds-m-ds-d"},
                showWeeks:true,
                // Show a status bar and use the format "l-cc-sp-d-sp-F-sp-Y" (e.g. Friday, 25 September 2009)
                statusFormat:"l-cc-sp-d-sp-F-sp-Y"
        };
        //alert(jQuery("#fd-selectDate").html());
        if(jQuery("#fd-selectDate").html()!=null){
           jQuery('#fd-selectDate').remove();
        }
        datePickerController.createDatePicker(opts);*/
// ]]>
</script>
    </td>

    </tr>
        <tr>
    <td width="144">
   
    </td>
    <td width="347"><input type="submit" style="background:#73AE0B; color:#fff; font-size:14px;" name="button" id="button" value="Submit" /></td>
    </tr>
    </table>
    </td>
    </tr>
        </tbody></table>
</form>
</div>
 <script type="text/javascript">
 jQuery(document).ready(function(){

 jQuery.validator.addMethod("alphaNumeric", function (value, element) {
        return this.optional(element) || /^[0-9a-zA-Z]+$/.test(value);
    }, "Username must contain only letters, numbers.");


 jQuery("#category_table").tablesorter({headers: { 2:{sorter: false},3:{sorter: false}, 4:{sorter: false}, 5:{sorter: false}}});

// show a simple loading indicator
		var loader = jQuery('<div id="loader"><img src="<?php echo Configure::read('base_url');?>img/loading.gif" alt="loading..." /></div>')
			.css({position: "relative", top: "1em", left: "25em"})
			.appendTo("body")
			.hide();
		jQuery().ajaxStart(function() {
			loader.show();
		}).ajaxStop(function() {
			loader.hide();
		}).ajaxError(function(a, b, e) {
			throw e;
		});

		var v = jQuery("#add_admin").validate({
                    rules: {
                    email:{
                        'required':true,
                        'email':true,
                         remote: {
                        url: baseurl+"users/emailcheck",
                        type: "post",
                        data: {
                          email: function() {
                            return $("#email").val();
                          }
                        }
                      }

                    } ,
                    cemail: {
                    required: true,
                    equalTo: '#email'
                    },
                    password: 'required',
                    cpassword: {
                    required: true,
                    equalTo: '#password'
                    },
                    username: {
                required: true,
                alphaNumeric: true,
                minlength: 5,
                remote: {
        url: baseurl+"users/usercheck",
        type: "post",
        data: {
          username: function() {
            return $("#username").val();
          }
        }
      }
    }
   },
      submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#result"
				});
			}
		});


                 });
      

 </script>
</body>
</html>